<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j"
	template="/WEB-INF/templates/template.xhtml">
			
	<ui:define name="breadcrumb">
		<ui:include src="breadcrumb.xhtml" />
	</ui:define>
	<ui:define name="menu">
		<ui:include src="/user/menu.xhtml" />
	</ui:define>
	<ui:define name="title">#{messages.obraSocialSearchHeader}</ui:define>
	<ui:define name="content">
		<h:form id="form">
			<div id="form_box">
				<div id="form_left">
					<h:panelGrid columns="3">
						<h:selectBooleanCheckbox value="#{obraSocialBean.input.buscarNombre}">
							<a4j:ajax event="change" 
								execute="@this" 
								render="buscarNombre"/>
						</h:selectBooleanCheckbox>
						<h:outputLabel styleClass="tarragona-search-label" 
							value="#{messages.obraSocialSearchNombre}:"/>
						<h:inputText id="buscarNombre"
							value="#{obraSocialBean.input.nombre}"
							disabled="#{!obraSocialBean.input.buscarNombre}">
						</h:inputText>
					</h:panelGrid>
				</div>	
				<div class="clearer"></div>			
			</div>
			<div id="butons">
				<h:panelGrid columns="2" width="100%" columnClasses="buttons-search,buttons-create">
					<h:commandButton value="#{messages.search}" 
						action="#{obraSocialBean.search}" />
	
					<h:commandButton value="#{messages.obraSocialCreate}" 
						action="#{obraSocialBean.showCreate}">
						<f:setPropertyActionListener value="#{facesContext.viewRoot.viewId}" 
							target="#{obraSocialBean.persistReturnView}" />
					</h:commandButton>									
				</h:panelGrid>
				<h:panelGrid columns="1"/>
				<rich:dataTable value="#{obraSocialBean.dataModel}" 
					iterationStatusVar="it" id="resultTable" var="result" rows="10"
					rendered="#{obraSocialBean.searchActive}">
 
        			<rich:column>
        				<f:facet name="header">
        					<h:outputText value="#{messages.obraSocialRNOS}"/>
        				</f:facet>
			        	<h:commandLink action="#{obraSocialBean.showEdit}">
			        		<h:outputText value="#{result.rnos}" />
        					<f:setPropertyActionListener value="#{result}" 
        						target="#{obraSocialBean.entity}" />
							<f:setPropertyActionListener value="#{facesContext.viewRoot.viewId}" 
								target="#{obraSocialBean.persistReturnView}" />        					
        				</h:commandLink>			        
        			</rich:column>

        			<rich:column>
        				<f:facet name="header">
        					<h:outputText value="#{messages.obraSocialNombre}"/>
        				</f:facet>
        				<h:outputText value="#{result.name}" />
					</rich:column>
        			<rich:column>
        				<f:facet name="header">
        					<h:outputText value="#{messages.obraSocialSigla}"/>
        				</f:facet>
        				<h:outputText value="#{result.sigla}" />
					</rich:column>
					<rich:column>
			        	<h:commandLink action="#{obraSocialBean.showEdit}">
        					<h:graphicImage value="/resources/icons/edit.gif" alt="edit"/>
        					<f:setPropertyActionListener value="#{result}" target="#{obraSocialBean.entity}" />
							<f:setPropertyActionListener value="#{facesContext.viewRoot.viewId}" 
								target="#{obraSocialBean.persistReturnView}" />        					
        				</h:commandLink>			        
			        
						<h:commandLink action="#{obraSocialBean.showRemove}">
        					<h:graphicImage value="/resources/icons/delete.gif" alt="delete"/>
        					<f:setPropertyActionListener value="#{result}" target="#{obraSocialBean.entity}" />
							<f:setPropertyActionListener value="#{facesContext.viewRoot.viewId}" 
								target="#{obraSocialBean.persistReturnView}" />        					
        				</h:commandLink>

			        	<h:commandLink action="#{obraSocialBean.showRevisionList}">
							<h:graphicImage value="/resources/icons/revision.png" alt="edit"/>
							<f:setPropertyActionListener value="#{result}" target="#{obraSocialBean.entity}" />
							<f:setPropertyActionListener value="#{facesContext.viewRoot.viewId}" 
								target="#{obraSocialBean.persistReturnView}" />
        				</h:commandLink>			        
						
					</rich:column>
        			<f:facet name="footer">
						<rich:dataScroller />
	        		</f:facet>
				</rich:dataTable>
				<h:panelGrid columns="2" width="100%" columnClasses="buttons-search,buttons-create"
					rendered="#{obraSocialBean.searchActive}">
					<h:commandButton value="#{messages.exportToExcel}" 
						action="#{obraSocialBean.exportToExcel}" />
				</h:panelGrid>
			</div>	
		</h:form>	
	</ui:define>	
</ui:composition>
